// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "requestHttpInfo.generated.h"

class UObject;
class UMK_SimpleHttpObj;
/**
 *返回的数据结构
 */
USTRUCT(BlueprintType)
struct SIMPLEHTTPREQUEST_API FSimpleHttpReplyData
{
	GENERATED_BODY()

	UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "SimpleHttpObj")
		FString userKey;
	UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "SimpleHttpObj")
		UObject* userObj;
	UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "SimpleHttpObj")
		FString RequestUrl;
	UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "SimpleHttpObj")
		FString ReplyData;
	UPROPERTY(BlueprintReadWrite, Category = "SimpleHttpObj")
		UMK_SimpleHttpObj* httpObj;

	FSimpleHttpReplyData():
		userObj(nullptr), httpObj(nullptr)
	{

	}

	FSimpleHttpReplyData(
		FString URL, FString DATA, UMK_SimpleHttpObj* httpObj
		,FString key = TEXT(""), UObject* obj = nullptr) :
		userKey(key),  userObj(obj),RequestUrl(URL), ReplyData(DATA), httpObj(httpObj)
		
	{

	}
};

DECLARE_DYNAMIC_DELEGATE_OneParam(F_SimpleHttpServerReturn,const FSimpleHttpReplyData&, ReplyData);


UENUM(BlueprintType)
enum class EMK_SimpleHttpPostTyp : uint8
{
	POST,
	GET,
	PUT,
	Delete
};


UENUM(BlueprintType)
enum class EMK_SimpleHttpLifeTyp : uint8
{
	//未初始化，没有绑定监听
	WaitInitialization,
	//正在请求（瞬时状态）
	StartRequest,
	//等待回复
	WaitReply,
	//已经回复或空闲
	IsReplyOrIdle
};

USTRUCT(BlueprintType)
struct SIMPLEHTTPREQUEST_API FMKSimpleHttpRequestData
{
	GENERATED_BODY()

public:

	//用户附加一个数据,回调时返回
	UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "SimpleHttpObj")
		FString  userkeywords;

	//用户附加一个数据,回调时返回
	UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "SimpleHttpObj")
		UObject* userLinkObj;


	UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "SimpleHttpObj")
		EMK_SimpleHttpPostTyp typ;

	UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "SimpleHttpObj")
		FString url;

	UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "SimpleHttpObj")
		FString data;

	UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "SimpleHttpObj")
		TMap<FString, FString> hardMap;


	FMKSimpleHttpRequestData();


	FMKSimpleHttpRequestData(
		EMK_SimpleHttpPostTyp typ_, FString url_, FString ContentType_, FString data_
		, FString keywords = TEXT(""), UObject* linkObj = nullptr);

	void SetContenType(FString type);
	
	void TryFinishUpHard();

	static FString GetHttpVerb(EMK_SimpleHttpPostTyp typ);
	
	static const FString Conten_Type;
	static const FString User_Agent;
	static const FString KeyValueContent;
	static const FString UTF8JsonContent;
	static const FString MultipartOrformDataContent;
	static const FString OctetStreamContent;

};


USTRUCT(BlueprintType)
struct SIMPLEHTTPREQUEST_API FMKHttpBodyData
{
	GENERATED_BODY()
public:

	FMKHttpBodyData() 
	{

	}

	UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "SimpleHttpObj")
		FString ContentDisposition = "form-data";

	UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "SimpleHttpObj")
		FString dataName;

	UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "SimpleHttpObj")
		FString fileName;

	UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "SimpleHttpObj")
		FString  ContentType;

	UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "SimpleHttpObj")
		TArray<uint8> data;

};

USTRUCT(BlueprintType)
struct SIMPLEHTTPREQUEST_API FMSimpleHttpParameter
{
	GENERATED_BODY()

public:

	UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "SimpleHttpObj")
	FString  key;
	UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "SimpleHttpObj")
	FString  value;
	UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "SimpleHttpObj")
	bool  isNumderValue;

	FMSimpleHttpParameter();
	FMSimpleHttpParameter(FString k, FString v, bool isNumder);

	FString ToParameterKV()const;
	FString ToJsonPart()const;
};